<template>
  <view>
    <view class="index-notice-box">
      <view class="index-notice-content-box">
        <view class="notice-icon-box">
          <image
            src="https://jy-yyzj.oss-cn-shanghai.aliyuncs.com/jdbx/icon/notice-mobile.png"
            class="notice-icon"
          ></image>
        </view>
        <view class="notice-line-box"></view>
        <view class="notice-content-box">
          <swiper
            class="swiper"
            :indicator-dots="false"
            :autoplay="true"
            :interval="2000"
            :duration="2000"
            :circular="true"
            :vertical="true"
            :display-multiple-items="1"
            easing-function="linear"
          >
            <swiper-item v-for="item in notice">
              <navigator :url="'/pages/index/detail?id=' + item.id">
                <view class="swiper-item">
                  {{ item.title }}
                </view>
              </navigator>
            </swiper-item>
          </swiper>
        </view>
        <view class="more-box" @click="toNotice()"> 更多 > </view>
      </view>
    </view>
 
    <view class="index-logo-box">
      <image
        src="/static/img/logo.png"
        mode="widthFix"
        class="index-logo"
      ></image>
    </view>

    <view class="nav">
      <view
        class="nav_item"
        :class="{ navActive: index == navIndex }"
        v-for="(item, index) in navList"
        :key="index"
        @click="itemClick(index)"
      >
        {{ item }}
      </view>
    </view>

    <view
      class="index-card"
      @tap="toG(item.id)"
      v-for="item in list"
      :key="item.id"
    >
      <view class="index-card-title">
        <image
          v-if="item.is_hot == 1"
          style="width: 100rpx; height: 40rpx; margin-right: 10rpx"
          src="../../static/img/01.png"
        ></image>
        <text>{{ item.name }}</text>
        <text class="index-card-bold index-card-red" v-if="item.type_name">·</text>
        <text class="index-card-red" v-if="item.type_name">
          {{ item.type_name }}
        </text>
      </view>
      <image
        :src="item.index_img"
        mode="widthFix"
        class="index-card-cover"
      ></image>
      <view class="index-card-memo">{{ item.memo }}</view>
      <view class="index-card-footer">
        <view class="index-card-btn">
          <text class="index-card-btn-num">{{ item.price }}</text>
          <text>{{item.unit}}</text>
        </view>
      </view>
    </view>
    <!-- <view class="index-card" @tap="toFg()">
      <view class="index-card-title">
        <text>太平洋家电雇主责任险</text>
        <text class="index-card-bold index-card-red">·</text>
        <text class="index-card-red">非高空版</text>
      </view>
      <image
        src="https://jy-yyzj.oss-cn-shanghai.aliyuncs.com/jdbx/h5/index2.png"
        mode="widthFix"
        class="index-card-cover"
      ></image>
      <view class="index-card-memo"
        >适用行业：适用于家电、家居、暖通等非高空安装维修。</view
      >
      <view class="index-card-footer">
        <view class="index-card-btn">
          <text class="index-card-btn-num">336</text>
          <text>元/人/年起</text>
        </view>
      </view>
    </view> -->
    <view class="index-footer-txt">年安保险销售服务有限公司</view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      notice: [],
      navIndex: 0,
      navList: ["精选方案", "空调家电行业", "光伏发电行业"],
      list: [],
    };
  },
  onLoad() {
    this.getData();
    this.getIndex(0);
  },
  methods: {
    getIndex(type) {
      this.ajax("index/index", {
        data: { type },
        success: (res) => {
          uni.hideLoading();
          console.log(res);
          this.list = res.msg;
        },
      });
    },
    getData() {
      uni.showLoading({
        title: "加载中",
      });
      this.ajax("index/getIndexNotice", {
        success: (res) => {
          uni.hideLoading();
          this.notice = res.msg;
          this.load = true;
        },
      });
    },
    // toFg() {
    //   uni.navigateTo({
    //     url: "/pages/bx/fg",
    //   });
    // },
    toG(id) {
		 
      if (id == 1) {
        uni.navigateTo({
          url: "/pages/bx/g",
        });
      } else if (id == 2) {
        uni.navigateTo({
          url: "/pages/bx/fg",
        });
      } else if (id == 4 || id == 8) {
        uni.navigateTo({
          url: "/pages/bx/jx?id=" + id,
        });
      } else if (id == 5) {
        uni.navigateTo({
          url: "/pages/bx/cdz",
        });
      } else if (id == 6) {
        uni.navigateTo({
          url: "/pages/bx/gfu",
        });
      } else if (id == 7) {
        uni.navigateTo({
          url: "/pages/bx/jxC",
        });
      }else if (id == 9) {
	    uni.navigateTo({
	      url: "/pages/bx/cdz2?id=" + id,
	    });
	  }
    },
    toNotice() {
      uni.navigateTo({
        url: "/pages/index/notice",
      });
    },
    toDetail(id) {
      uni.navigateTo({
        url: "/pages/index/detail?id=" + id,
      });
    },
    itemClick(index) {
      this.navIndex = index;
      this.getIndex(index);
    },
  },
};
</script>

<style lang="less">
@import url("@/static/css/index/index.css");
.nav {
  margin: 24rpx 24rpx 0 24rpx;
  background: #fff;
  height: 66rpx;
  line-height: 66rpx;
  box-shadow: 0px 0px 12rpx rgba(0, 0, 0, 0.06);
  border-radius: 10rpx;
  display: flex;
  .navActive {
    width: 176rpx;
    height: 78rpx !important;
    background-image: url("../../static/img/02.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    color: #fff;
  }
  .nav_item {
    width: 176rpx;
    height: 40rpx;
	margin-right: 10rpx;
	padding: 0 10rpx;
    font-size: 28rpx;
    text-align: center;
  }
}
</style>
